#pragma once
#include <string>
// #include "Reactor.hpp" //不可以包含会造成两者相互包含
#include <memory>
#include <sys/epoll.h>
#include<functional>
#include "Socket.hpp"
using namespace SocketModule;
//我们从网络层读取的数据 要交给上层 因此我们的参数是string上层经过协议处理后交给业务层接着给我们返回数据
//接着发送给客户端
using func1_t=std::function<std::string(std::string&)>;
class Reactor; // 声明
class Connection
{
public:
    virtual ~Connection() = default;
    virtual int GetFd() = 0;
    virtual void RECV() = 0;
    virtual void SEND() = 0;
    virtual void Excepter() = 0;
    virtual InetAddr* GetClient() = 0;
    // virtual void Write(int fd);
    Connection()
        : _own(nullptr),
          _event(-1)
    {
    }
    void SetEvent(uint32_t event)
    {
        _event = event;
    }
    uint32_t GetEvent()
    {
        return _event;
    }
    Reactor *GetOwner()
    {
        return _own;
    }
    void SetOwn(Reactor *own)
    {
        _own = own;
    }
    void Register(func1_t func)
    {
        _func=func;
    }
private:
    Reactor *_own;
    uint32_t _event;
public:
    //回调函数 让上层调用
    func1_t _func;
};